package com.xian.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xian.common.annotation.Log;
import com.xian.common.core.controller.BaseController;
import com.xian.common.core.domain.AjaxResult;
import com.xian.common.enums.BusinessType;
import com.xian.manage.domain.HandmadePerson;
import com.xian.manage.service.IHandmadePersonService;
import com.xian.common.utils.poi.ExcelUtil;
import com.xian.common.core.page.TableDataInfo;

/**
 * 继承人管理Controller
 * 
 * @author Hanys
 * @date 2025-04-01
 */
@RestController
@RequestMapping("/manage/person")
public class HandmadePersonController extends BaseController
{
    @Autowired
    private IHandmadePersonService handmadePersonService;

    /**
     * 查询继承人管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:person:list')")
    @GetMapping("/list")
    public TableDataInfo list(HandmadePerson handmadePerson)
    {
        startPage();
        List<HandmadePerson> list = handmadePersonService.selectHandmadePersonList(handmadePerson);
        return getDataTable(list);
    }

    /**
     * 导出继承人管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:person:export')")
    @Log(title = "继承人管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HandmadePerson handmadePerson)
    {
        List<HandmadePerson> list = handmadePersonService.selectHandmadePersonList(handmadePerson);
        ExcelUtil<HandmadePerson> util = new ExcelUtil<HandmadePerson>(HandmadePerson.class);
        util.exportExcel(response, list, "继承人管理数据");
    }

    /**
     * 获取继承人管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:person:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(handmadePersonService.selectHandmadePersonById(id));
    }

    /**
     * 新增继承人管理
     */
    @PreAuthorize("@ss.hasPermi('manage:person:add')")
    @Log(title = "继承人管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HandmadePerson handmadePerson)
    {
        return toAjax(handmadePersonService.insertHandmadePerson(handmadePerson));
    }

    /**
     * 修改继承人管理
     */
    @PreAuthorize("@ss.hasPermi('manage:person:edit')")
    @Log(title = "继承人管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HandmadePerson handmadePerson)
    {
        return toAjax(handmadePersonService.updateHandmadePerson(handmadePerson));
    }

    /**
     * 删除继承人管理
     */
    @PreAuthorize("@ss.hasPermi('manage:person:remove')")
    @Log(title = "继承人管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(handmadePersonService.deleteHandmadePersonByIds(ids));
    }
}
